package com.yubest.junit.asyntask;

import cn.hutool.core.thread.ThreadFactoryBuilder;

import java.util.concurrent.*;

/**
 * 线程池
 *
 * @Author: hweiyu
 * @Date: 2022/10/27 16:39
 */
public class ThreadPool {

    public static ExecutorService create() {
        return new ThreadPoolExecutor(
                8,
                20,
                30L, TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable>(10),
                new ThreadFactoryBuilder().setNamePrefix("async-task-%d").setDaemon(true).build(),
                new ThreadPoolExecutor.CallerRunsPolicy());
    }

}
